package cn.terminus.data.customer.contractinfo.impl;

import cn.terminus.common.customer.bean.analysis.AnalysisYearDto;
import cn.terminus.common.customer.bean.analysis.ContractTypeRoomDetail;
import cn.terminus.common.customer.bean.contractinfo.dto.*;
import cn.terminus.common.customer.bean.custompurposeroom.dto.CustomPurposeRoomResultDto;
import cn.terminus.data.customer.contractinfo.dao.ContractInfoDao;
import cn.terminus.data.customer.contractinfo.mapper.ContractInfoMapper;
import cn.terminus.result.common.page.TerminusPageAble;
import cn.terminus.result.common.page.TerminusPageInfo;
import cn.terminus.result.common.util.BeanCopyUtils;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * 合同信息表(ContractInfo)表服务实现类
 *
 * @author makejava
 * @since 2021-07-21 11:01:06
 */
@Repository
public class ContractInfoDaoImpl implements ContractInfoDao {
    @Resource
    private ContractInfoMapper contractInfoMapper;

    @Override
    public Integer add(ContractInfoNewDto dto) {
        return contractInfoMapper.add(dto);
    }

    @Override
    public Integer update(ContractInfoEditDto dto) {
        return contractInfoMapper.update(dto);
    }

    @Override
    public List<ContractInfoResultDto> gets(ContractInfoGetsDto dto) {
        return contractInfoMapper.gets(dto);
    }

    @Override
    public List<ContractInfoResultDto> query(ContractInfoQueryDto dto) {
        return contractInfoMapper.query(dto);
    }

    @Override
    public List<ContractInfoResultDto> queryWithPage(ContractPageQueryDto dto) {
        return contractInfoMapper.queryWithPage(dto);
    }

    @Override
    public Integer delete(ContractInfoDeleteDto dto) {
        return contractInfoMapper.delete(dto);
    }

    @Override
    public TerminusPageAble<ContractInfoResultDto> page(ContractInfoQueryDto dto, TerminusPageInfo page) {
        PageHelper.startPage(page.getCurrentPage(), page.getPageSize());
        Page<ContractInfoResultDto> result = (Page<ContractInfoResultDto>) contractInfoMapper.query(dto);
        return new TerminusPageAble<>(BeanCopyUtils.copy(result.getResult(), ContractInfoResultDto.class), page, result.getTotal());
    }

    @Override
    public List<ContractInfoResultDto> getByCustomerId(Long cboCustomerId) {
        return contractInfoMapper.getByCustomerId(cboCustomerId);
    }

    @Override
    public Integer deleteByIds(List<Long> ids) {
        return contractInfoMapper.deleteByIds(ids);
    }

    @Override
    public List<CustomPurposeRoomResultDto> geturposeRoomInfoByContractIds(List<Long> contractIdList) {
        return contractInfoMapper.geturposeRoomInfoByContractIds(contractIdList);
    }

    @Override
    public Integer getByCustomerIdList(List<Long> ids) {
        return contractInfoMapper.getByCustomerIdList(ids);
    }

    @Override
    public Integer analysisTotalContract(AnalysisYearDto dto) {
        return contractInfoMapper.analysisTotalContract(dto);
    }

    @Override
    public List<ContractTypeRoomDetail> queryByIds(List<Long> ids) {

        return contractInfoMapper.queryByIds(ids);
    }
}
